package com.li.onjava8.concurrent.cf.example.cake;

import com.li.onjava8.concurrent.utils.Nap;

import java.util.concurrent.CompletableFuture;

/**
 * 3. 最后，我们创建了一批糖，并用它对蛋糕进行糖化：
 * @author li
 * @date 2023/10/31 15:16
 */
public class FrostedCake {
    public FrostedCake(Baked baked, Frosting frosting) {
        new Nap(0.1);
    }

    @Override
    public String toString() {
        return "FrostedCake";
    }

    public static void main(String[] args) {
        CompletableFuture<Batter> batter = Batter.mix();
        Baked.batch(batter).forEach(
                baked -> baked.thenCombineAsync(Frosting.make(), (cake, frosting) -> new FrostedCake(cake, frosting))
                        .thenAcceptAsync(System.out::println)
                        .join()
        );
    }
}